package com.itheima.chapter08.set.map;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

//map集合获取功能
public class Mapdemo2 {
    public static void main(String[] args) {
        Map<String,String> map =new HashMap<>();
        map.put("张无忌","赵敏");
        map.put("郭靖","黄蓉");
        map.put("杨过","小龙女");
        map.put("钱钱","太子");
        //根据键获取值
        String s = map.get("杨过");
        System.out.println(s);
        String s1 = map.get("杨及");
        System.out.println(s1);
        System.out.println("==============");
        //获取所有键集合
        Set<String> keySet = map.keySet();
        for (String string : keySet) {
            System.out.println(string);
        }
        System.out.println("==============");
                //获取所有值集合
        Collection<String> values = map.values();
        for (String value : values) {
            System.out.println(value);
        }
    }
}
